$(document).ready(function () {
    layui.use('form', function () {
        var form = layui.form;
        form.render();

        getRole();

    });
});

function getRole() {

    var id = $('#id').val();

    ajax(
        "/admin/role/getRole", "POST",
        { roleId: id }
        ,true, true, false
    ).done(function (returnData) {

        $("input[name='roleId']").val(returnData.roleId);
        $("input[name='roleKey']").val(returnData.roleKey);
        $("input[name='roleName']").val(returnData.roleName);
        $("input[name='roleSort']").val(returnData.roleSort);
        $(":radio[name='roleStatus'][value='" + returnData.roleStatus + "']").prop("checked", true);
        form.render();

    });

}

function editRole() {

    var formJSON = $("#role-submit-form").serializeObject();

    // 编辑菜单
    ajax(
        "/admin/role/editRole", "POST",
        formJSON, true, true, true
    ).done(function () {
        loadingPage("/admin/role/role");
    });

}